<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


if ( ! function_exists('la_redirect'))
{
	function la_redirect($uri , $message)
	{
		if ( ! preg_match('#^https?://#i', $uri)) {
			$uri = site_url($uri);
		}
		$_SESSION['flash_message'] = $message;
		header("Location: ".$uri, TRUE, 302);
		exit(0);
	}
	
}

if (! function_exists('current_user')) {
	function current_user($param = 'user_id') {
		$CI =& get_instance();
		return $CI->session->userdata($param);
	}
}

if(!function_exists("la_substr")) {
	function la_substr($string, $len, $need = 1) {
		if(mb_strlen($string) < $len) {
			return $string;
		} else {
			$return = mb_substr($string, $len);
			if($need) {
				$return .= "..";
			}
			return $return;
		}
	}
}

if (! function_exists('ads')) {
	function ads($type = 'sotry') {
		$CI =& get_instance();
		$sql = " select * from emergencies where is_top=1 and top_end_time>'" . date("Y-m-d H:i:s") . "' order by top_start_time limit 5";
		$result = $CI->db->query($sql)->result_array();
		return $result;
	}
}
